<?php
//namespace App\Helpers;

function rq($key=null, $default=null)
{
    if (!$key) return Request::all();
    return Request::get($key, $default);
}

function pageinate($page = 1, $limit = 16)
{
    $limit = $limit ? : 16;
    $skip = ($page ? $page - 1 : 0) * $limit;
    return [$limit, $skip];
}

function err($msg = null)
{
    return ['status' => 0, 'msg' => $msg];
}

function suc($data_to_merge = [])
{
    $data = ['status' => 1, 'data' => []];
    if ($data_to_merge) {
        $data['data'] = array_merge($data['data'], $data_to_merge);
    }
    return $data;
}